package sorts

object SortUtil {
    fun quickSort(arr: IntArray, start_: Int, end_: Int) {
        var start = start_
        var end = end_
        val pivot = start
        while (start < end) {
            while (start < end && arr[end] >= arr[pivot]) end--
            while (start < end && arr[start] <= arr[pivot]) start++
            swap(arr, start, end)
        }
        swap(arr, start, pivot)
    }


    private fun swap(arr: IntArray, index1: Int, index2: Int) {
        val temp = arr[index1]
        arr[index1] = arr[index2]
        arr[index2] = temp
    }
}